package at.fhooe.mcm12.java.sensors;

import java.rmi.RemoteException;

import at.fhooe.mcm12.java.enums.SensorType;
import at.fhooe.mcm12.java.interfaces.ISensorListener;
import at.fhooe.mcm12.java.sensors.data.SensorValue;

public abstract class PollSensor extends AbstractSensor implements Runnable{

	protected PollSensor() throws RemoteException {
		super();
		m_sensorType = SensorType.Poll;
	}

	public static final int REFRESH_RATE = 500;
	
	public SensorValue getDataType(){
		return getSensorValue();
	}
	
	public abstract SensorValue getSensorValue();
	public abstract void refreshSensorValue();
	
	public void run()
	{
		try
		{
			while(true)
			{
				Thread.sleep(REFRESH_RATE);
				
				if(isActive()){
					refreshSensorValue();
				}
			}
		}
		catch(InterruptedException ie)
		{
			System.err.println(ie.getMessage());
		}
	}
	
	
	public void addSensorListener(ISensorListener _listener)
	{
	}
	
	public void removeSensorListener(ISensorListener _listener)
	{
	}
	
	public int getUpdateInterval()
	{
		return 0;
	}
	
	public void setUpdateInterval(int _updateInterval)
	{
	}
}
